# author destiny1
# Date: 2023/8/5 18:35
from threading import Thread
import time
g_num = 100
def work1():
    global g_num
    #对于全局变量 此处必须加 global 否则会报错
    for i in range(3):
        g_num += 1
        print("----in work1, g_num is %d---"%g_num)

def work2():
    global g_num
    print("----in work2, g_num is %d---" % g_num)

if __name__ == '__main__':
    t1 = Thread(target=work1)
    t1.start()
    time.sleep(1)
    t2 = Thread(target=work2)
    t2.start()
